package cn.fafu.fafu_record.service;

import cn.fafu.fafu_record.entity.User;
import cn.fafu.fafu_record.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.stereotype.Service;

import java.util.Optional;


@Service
public class UserService {

    @Autowired
    UserMapper userMapper;



    public User findUserById(Integer id){
        Optional<User> users = userMapper.findById(id);
        User user = users.get();
        return user;
    }

    public User findUserByUsername(String username){
        User user = new User("13313767166");
        Example<User> example = Example.of(user);
        Optional<User> one = userMapper.findOne(example);
        User _user = one.get();
        return _user;
    }
}
